package org.jeecg.modules.power.device.service.impl;

import lombok.RequiredArgsConstructor;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.app.util.NumberArithmeticUtils;
import org.jeecg.modules.app.v1.util.Const;
import org.jeecg.modules.power.device.entity.YlDevice;
import org.jeecg.modules.power.device.entity.YlDeviceRecords;
import org.jeecg.modules.power.device.entity.YlWarehouse;
import org.jeecg.modules.power.device.entity.YlWarehouseRecords;
import org.jeecg.modules.power.device.mapper.YlWarehouseRecordsMapper;
import org.jeecg.modules.power.device.service.IYlDeviceRecordsService;
import org.jeecg.modules.power.device.service.IYlWarehouseRecordsService;
import org.jeecg.modules.power.device.service.IYlWarehouseService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @Description: 仓库入库出库记录表
 * @Author: jeecg-boot
 * @Date:   2024-07-26
 * @Version: V1.0
 */
@Service
public class YlWarehouseRecordsServiceImpl extends ServiceImpl<YlWarehouseRecordsMapper, YlWarehouseRecords> implements IYlWarehouseRecordsService {

    /**
     * 保存设备入库记录
     * @param device
     */
    @Transactional
    public boolean saveDeviceRecords(YlDevice device,YlWarehouse warehouse){
        if(oConvertUtils.isEmpty(warehouse))return false;
        YlWarehouseRecords warehouseRecords = new YlWarehouseRecords();
        warehouseRecords.setDeviceId(device.getId());
        warehouseRecords.setHouseName(warehouse.getHouseName());
        warehouseRecords.setDeviceMac(device.getDeviceMac());
        warehouseRecords.setHouseId(device.getBusinessId());
        warehouseRecords.setRemark(Const.RK);
        warehouseRecords.setCreateTime(device.getCreateTime());
        this.save(warehouseRecords);
        return true;
    }


}
